binary = $(shell go list)
version = $(shell git log --pretty=format:'git.%h.aI%aI' -1)
staticx_binary = $(binary).sx
source = $(wildcard *.go */*.go)

all: $(binary) $(nginx_default_binary)

$(staticx_binary): $(binary)
	staticx $< $@

$(binary): $(source)
	go build -ldflags "-X main.version=$(version) -X main.binary=$(binary)" $@

lint:
	golangci-lint run --verbose

clean:
	rm -rf $(binary) $(nginx_default_binary) $(expect)
	rm -rf build dist
	rm -rf $(wildcard *.spec)

.PHONY: all clean
